package com.zk.mybatis.plus.springboot.mapper;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zk.mybatis.plus.springboot.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper extends BaseMapper<User> {

    User findById(Long id);
    @Select("UPDATE tb_user SET age = age + #{age} ${ew.customSqlSegment}")
    void increaseAgeByIds(@Param("age") int age, @Param("ew") QueryWrapper<User> wrapper);

    @Select("SELECT u.* FROM tb_user u INNER JOIN address a ON u.id = a.user_id ${ew.customSqlSegment}")
    List<User> queryUserByWrapper(@Param("ew")QueryWrapper<User> wrapper);
}